-
-
Notifications
You must be signed in to change notification settings - Fork 14.4k
resolve: Replace Macros20NormalizedIdent with IdentKey
#151550
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Conversation
|
@bors try @rust-timer queue |
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
resolve: Replace `Macros20NormalizedIdent` with `IdentKey`
This comment has been minimized.
This comment has been minimized.
|
Finished benchmarking commit (0b62e28): comparison URL. Overall result: ❌✅ regressions and improvements - please read the text belowBenchmarking this pull request means it may be perf-sensitive – we'll automatically label it not fit for rolling up. You can override this, but we strongly advise not to, due to possible changes in compiler perf. Next Steps: If you can justify the regressions found in this try perf run, please do so in sufficient writing along with @bors rollup=never Instruction countOur most reliable metric. Used to determine the overall result above. However, even this metric can be noisy.
Max RSS (memory usage)Results (primary -1.7%, secondary -1.0%)A less reliable metric. May be of interest, but not used to determine the overall result above.
CyclesResults (primary 0.7%, secondary 5.8%)A less reliable metric. May be of interest, but not used to determine the overall result above.
Binary sizeResults (secondary -0.0%)A less reliable metric. May be of interest, but not used to determine the overall result above.
Bootstrap: 470.684s -> 470.503s (-0.04%) |
181aae7 to
2f655fb
Compare
|
r? @fee1-dead rustbot has assigned @fee1-dead. Use |
|
r? @nnethercote |
|
(I also want to try passing the |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Looks reasonable. A couple of minor comments.
compiler/rustc_resolve/src/lib.rs
Outdated
|
|
||
| /// Combination of a symbol and its macros 2.0 normalized hygiene context. | ||
| /// Used as a key in all kinds of name containers, including modules (as a part of slightly larger | ||
| /// `BindingKey`) and preludes. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I'd like some of the details from the PR description to be added here. E.g. that this is like Macros20NormalizedIdent but without the spans, and it exists as an optimization to avoid useless span operations when doing hash/eq.
Also, the detail about orig_ident_span often being passed around (and it being unnormalized) would be useful.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
E.g. that this is like Macros20NormalizedIdent but without the spans
Macros20NormalizedIdent is no longer used and removed in this PR, so we cannot make this comparison anymore :)
compiler/rustc_resolve/src/lib.rs
Outdated
| mod hygiene { | ||
| use rustc_span::SyntaxContext; | ||
|
|
||
| /// An newtype around `SyntaxContext` that can only keep contexts produced by |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
| /// An newtype around `SyntaxContext` that can only keep contexts produced by | |
| /// A newtype around `SyntaxContext` that can only keep contexts produced by |
compiler/rustc_resolve/src/lib.rs
Outdated
| } | ||
|
|
||
| /// Combination of a symbol and its macros 2.0 normalized hygiene context. | ||
| /// Used as a key in all kinds of name containers, including modules (as a part of slightly larger |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
"All kinds" is ambiguous. Does it mean "every kind" or "many kinds"?
|
@rustbot author |
|
Reminder, once the PR becomes ready for a review, use |
This comment has been minimized.
This comment has been minimized.
2f655fb to
5726e37
Compare
|
This PR was rebased onto a different main commit. Here's a range-diff highlighting what actually changed. Rebasing is a normal part of keeping PRs up to date, so no action is needed—this note is just to help reviewers. |
|
Updated. |
|
Thanks. @bors r+ |
This comment has been minimized.
This comment has been minimized.
What is this?This is an experimental post-merge analysis report that shows differences in test outcomes between the merged PR and its parent PR.Comparing 1e5065a (parent) -> de6d33c (this PR) Test differencesShow 44 test diffs44 doctest diffs were found. These are ignored, as they are noisy. Test dashboardRun cargo run --manifest-path src/ci/citool/Cargo.toml -- \
test-dashboard de6d33c033441c5880b863f94d7a3ec8cad141bd --output-dir test-dashboardAnd then open Job duration changes
How to interpret the job duration changes?Job durations can vary a lot, based on the actual runner instance |
|
Finished benchmarking commit (de6d33c): comparison URL. Overall result: ❌✅ regressions and improvements - please read the text belowOur benchmarks found a performance regression caused by this PR. Next Steps:
@rustbot label: +perf-regression Instruction countOur most reliable metric. Used to determine the overall result above. However, even this metric can be noisy.
Max RSS (memory usage)Results (primary -2.6%, secondary -0.4%)A less reliable metric. May be of interest, but not used to determine the overall result above.
CyclesResults (primary -10.0%, secondary -2.1%)A less reliable metric. May be of interest, but not used to determine the overall result above.
Binary sizeResults (primary -0.0%, secondary -0.0%)A less reliable metric. May be of interest, but not used to determine the overall result above.
Bootstrap: 474.687s -> 474.844s (0.03%) |
This is a continuation of #150741 and #150982 based on the ideas from #151491 (comment).
Before this PR
Macros20NormalizedIdentwas used as a key in various "identifier -> its resolution" maps inrustc_resolve.Macros20NormalizedIdentis a newtype aroundIdentin whichSyntaxContext(packed insideSpan) is guaranteed to be normalized usingnormalize_to_macros_2_0.This type is also used in a number of functions looking up identifiers in those maps.
Macros20NormalizedIdentstill contains span locations, which are useless and ignored during hash map lookups and comparisons due toIdent's specialPartialEqandHashimpls.This PR replaces
Macros20NormalizedIdentwith a new type calledIdentKey, which contains only a symbol and a normalized unpacked syntax context. (E.g.IdentKey==Macros20NormalizedIdentminus span locations.)So we avoid keeping additional data and doing some syntax context packing/unpacking.
Along with
IdentKeyyou can often seeorig_ident_span: Spanbeing passed around.This is an unnormalized span of the original
Identfrom whichIdentKeywas obtained.It is not used in map keys, but it is used in a number of other scenarios:
allow_unstablechecksThis is because
normalize_to_macros_2_0normalization is lossy and the normalized spans / syntax contexts no longer contain parts of macro backtraces, while the original span contains everything.